package com.zre.controller;

import com.alibaba.fastjson.JSON;

/**
 * Created: 上午12:31-2018/8/21
 * author:
 * desc: 基础Controller
 * version: 1.0
 */
public class BaseController {

    private static final Integer okCode = 200;
    private static final Integer errCode = 500;
    private static final String okMsg = "ok";
    private static final String errMsg = "error";

    public String ok(Object data){

        Meta meta = new Meta(okCode,okMsg,data);

        return JSON.toJSONString(meta);
    }

    public Object error(Object data){

        Meta meta = new Meta(errCode,errMsg,data);
        return JSON.toJSONString(meta);
    }




    public static class Meta{

        public Meta(Integer code, String msg, Object data) {
            this.code = code;
            this.msg = msg;
            this.data = data;
        }

        private Integer code;
        private String msg;
        private Object data;

        public Integer getCode() {
            return code;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        public Object getData() {
            return data;
        }

        public void setData(Object data) {
            this.data = data;
        }
    }
}
